class login{
    private String userName;
    private String passWord;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public void logInfo(String userName, String passWord){
        if(!this.userName.equals(userName)){
            throw new UserNameException("用户名错误异常");
        }

        if(!this.passWord.equals(passWord)){
            throw new RuntimeException("用户名错误异常");
        }

        System.out.println("登陆成功");
    }
}

public class Test {
    public static void main(String[] args) {
        login login=new login();
        login.setPassWord("123");
        login.setUserName("123");

        login.logInfo("123","123");
    }
}
